<template>
  <div>
    <h3>ref用在组件上</h3>
    <!-- 1. 组件上加ref属性  -->
    <jack ref="jack"></jack>
    <button @click="fn">按钮</button>
  </div>
</template>

<script>
import Jack from './components/jack.vue'
export default {
  components: {
    Jack
  },
  methods: {
    fn() {
      console.log(this.$refs.jack);
      // 2. this.$refs.xxx  获取组件
      this.$refs.jack.sayHi()
    }
  }
}
</script>

<style>

</style>